package com.purong.purong.fragment;

import android.content.Intent;
import android.text.TextPaint;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.purong.purong.R;
import com.purong.purong.activity.MainActivity;
import com.purong.purong.util.CommonUtil;
import com.purong.purong.util.SharePreUtil;

/**
 * Created by zengwenjie on 2017/12/12.
 */
public class GuideFragment extends BaseFragment {
    public static final int PAGE_ONE=0X001,PAGE_TWO=0X002,PAGE_THREE=0X003,PAGE_FOUR=0X004;
    private int page;
    private ImageView img,confirm;
    private TextView title,content;

    @Override
    public void initBundle() {
        page=getArguments().getInt("PAGE");
    }

    @Override
    public int getRootViewId() {
        return R.layout.fragment_guide_four;
    }

    @Override
    public void initView(View rootView) {
        img=(ImageView)rootView.findViewById(R.id.img);
        confirm=(ImageView)rootView.findViewById(R.id.confirm);
        title=(TextView)rootView.findViewById(R.id.title);
        content=(TextView)rootView.findViewById(R.id.content);
        int size= CommonUtil.getScreenWidth(getActivity())-CommonUtil.dip2px(getActivity(),48);
        img.setLayoutParams(new LinearLayout.LayoutParams(size,size));
//        TextPaint paint = title.getPaint();
//        paint.setFakeBoldText(true);
        if (page==PAGE_FOUR){
            confirm.setVisibility(View.VISIBLE);
            confirm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    SharePreUtil.getInstance(getActivity()).setShowIntroduce(false);
                    Intent intent=new Intent(getActivity(),MainActivity.class);
                    startActivity(intent);
                    getActivity().finish();
                }
            });
        }
    }

    @Override
    public void initData() {
        switch (page){
            case PAGE_ONE:
                img.setImageResource(R.drawable.guide_one);
                title.setText("银行贷");
                content.setText("秒批额度，轻松几步搞定贷款");
                break;
            case PAGE_TWO:
                img.setImageResource(R.drawable.guide_two);
                title.setText("信用卡");
                content.setText("提交申请，闪电审批发卡");
                break;
            case PAGE_THREE:
                img.setImageResource(R.drawable.guide_three);
                title.setText("精选快讯");
                content.setText("快讯推送，抢先知晓业内新闻");
                break;
            case PAGE_FOUR:
                img.setImageResource(R.drawable.guide_four);
                title.setText("普融金融");
                content.setText("中小企业普惠金融O2O模式领导者");
                break;
        }
    }
}
